package com.example.redis;

import com.example.websocket.WebSocketProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
public class MsgHandler {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private WebSocketProcess webSocketProcess;

    public void handleMessage(String key){
        key = key.replaceAll("\"","");
        String msg = (String) redisTemplate.opsForValue().get(key);
        try {
            webSocketProcess.sendMessage(Long.valueOf(key),msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
